#include "brick.h"
#include <iostream>
#include "game_state.h"

using namespace std;
Brick::~Brick()
{
}
Brick::Brick(float randx, float sizex = 0.5f, float sizey = 0.5f, float sizez = 0.5f) : BlockObject(Block(sizex, sizey, sizez))
{
    pos = glm::vec3(randx, 0.0f, -10.0f);
    block.setTexture(Texture("..\\assets\\image\\container2.png", GL_TEXTURE_2D));
    block.setSpecTexture(Texture("..\\assets\\image\\container2_specular.png", GL_TEXTURE_2D));
}

void Brick::draw(Shader shader)
{
    block.draw(shader, pos.x, pos.y, pos.z);
}

void Brick::update(float dt)
{
    float speed = 1.5;
    pos.z = pos.z + dt * speed;
    glm::vec3 blockSize = block.getSize();
    if (pos.z > -blockSize.z)
    {
        droped = true;
        GameState::lost = true;
    }
}